{extend name="main/index" /}
{block name="main"}
<style type="text/css">
    .form-group .col-xs-10{
        width:200px; 
        height:40px; 
        line-height:40px; 
        border:1px solid #CCC; 
    }
    .form-group .default{
       width:200px; 
        height:32px; 
        line-height:32px; 
        color:#999;
    }
    .form-group .error{
        height:32px; 
        line-height:32px; 
        color:#F00; 
    }
    .form-group .success{
        height:32px; 
        line-height:32px; 
        color:#096; 
    }
</style>
<div class="main-content">

    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="{:url('admin/manpower/bulletin')}">招聘公告</a>
            </li>
            <li class="active">修改招聘公告</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>
    <div class="page-content">
        <h3 class="header smaller lighter blue">修改招聘公告</h3>
        <div class="col-xs-12">
            <form class="form-horizontal" action="{:url('admin/manpower/doeditbulletin',['id' => $res['id']])}" enctype="multipart/form-data" method="post" onSubmit="return checkForm()">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 招聘单位: </label>

                    <div class="col-sm-9">
                        <input type="text" name="recruitment_unit" class="col-xs-10 col-sm-5" value="{$res['recruitment_unit']}" id="unit" onBlur="checkunit()" oninput="checkunit()"/>
                        <span class="default" id="unitErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">招聘职位: </label>

                    <div class="col-sm-9">
                        <input type="text" name="recruitment_position" class="col-xs-10 col-sm-5" value="{$res['recruitment_position']}" id="position" onBlur="checkposition()" oninput="checkposition()"/>
                        <span class="default" id="positionErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">招聘人数: </label>

                    <div class="col-sm-9">
                        <input type="text" name="recruitment_num" class="col-xs-10 col-sm-5" value="{$res['recruitment_num']}" id="num" onBlur="checknum()" oninput="checknum()"/>
                        <span class="default" id="numErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>


                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">职位要求: </label>

                    <div class="col-sm-9">
                        <input type="text" name="job_description" class="col-xs-10 col-sm-5" value="{$res['job_description']}" id="description" onBlur="checkdescription()" oninput="checkdescription()"/>
                        <span class="default" id="descriptionErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">公司福利: </label>

                    <div class="col-sm-9">
                        <input type="text" name="orporate_welfare" class="col-xs-10 col-sm-5" value="{$res['orporate_welfare']}" id="welfare" onBlur="checkwelfare()" oninput="checkwelfare()"/>
                        <span class="default" id="welfareErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">薪资: </label>

                    <div class="col-sm-9">
                        <input type="text" name="salary" class="col-xs-10 col-sm-5" value="{$res['salary']}" id="salary" onBlur="checksalary()" oninput="checksalary()"/>
                        <span class="default" id="salaryErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">项目Logo: </label>

                    <div class="col-sm-9">
                        <input type="file" name="image" class="col-xs-10 col-sm-5" value="{$res['image']}"/>
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-tags">状态</label>
                    <div class="col-sm-9">
                        <input name="status" type="radio" value="1" {$res['status']==1?'checked':''} />开启 |
                        <input name="status" value="0" type="radio" {$res['status']==0?'checked':''} />关闭
                    </div>
                </div>
                <!--<div class="clearfix form-actions">-->

                <div >
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>

                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="icon-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<script type="text/javascript"> 
    function checkForm(){ 
        var nametip = checkunit(); 
        var requirement = checkposition();  
        var content = checknum(); 
        var logging = checkdescription(); 
        var welfare = checkwelfare();
        var salary = checksalary();
        return nametip && requirement && content && logging && welfare && salary;
    } 
    
    function checkunit(){ 
        var username = document.getElementById('unit'); 
        var errname = document.getElementById('unitErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/;
        if(username.value.length == 0){ 
            errname.innerHTML="招聘单位不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="招聘单位不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    } 

    function checkposition(){ 
        var username = document.getElementById('position'); 
        var errname = document.getElementById('positionErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="招聘职位不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="招聘职位不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checknum(){ 
        var username = document.getElementById('num'); 
        var errname = document.getElementById('numErr');
        var pattern = /^\d+$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="招聘人数不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="招聘人数不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkdescription(){ 
        var username = document.getElementById('description'); 
        var errname = document.getElementById('descriptionErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]+$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="职位要求不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="职位要求不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkwelfare(){ 
        var username = document.getElementById('welfare'); 
        var errname = document.getElementById('welfareErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]+$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="公司福利不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="公司福利不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checksalary(){ 
        var username = document.getElementById('salary'); 
        var errname = document.getElementById('salaryErr'); 
        var pattern = /^[1-9]([0-9]+)?$/;
        if(username.value.length == 0){ 
            errname.innerHTML="薪资不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="薪资不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

</script>

{/block}